<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveRecord::Reflection::MacroReflection</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Class</span> 
            ActiveRecord::Reflection::MacroReflection 
            
                <span class="parent">&lt; 
                    
                    <a href="../../Object.html">Object</a>
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/activerecord/lib/active_record/reflection_rb.html">activerecord/lib/active_record/reflection.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p><a href="../Base.html">Base</a> class for AggregateReflection and
AssociationReflection. Objects of AggregateReflection and
AssociationReflection are returned by the <a
href="ClassMethods.html">Reflection::ClassMethods</a>.</p>

<pre>MacroReflection
  AggregateReflection
  AssociationReflection
    ThroughReflection</pre>

    </div>
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>#</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="MacroReflection.html#method-i-3D-3D">==</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>C</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="MacroReflection.html#method-i-class_name">class_name</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>K</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="MacroReflection.html#method-i-klass">klass</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="MacroReflection.html#method-c-new">new</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    
      <!-- Section attributes -->
      <div class="sectiontitle">Attributes</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [R]
            </td>
            <td class='attr-name'>active_record</td>
            <td class='attr-desc'></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [R]
            </td>
            <td class='attr-name'>macro</td>
            <td class='attr-desc'><p>Returns the macro type.</p>

<p><code>composed_of :balance, class_name: 'Money'</code> returns
<code>:composed_of</code> <code>has_many :clients</code> returns
<code>:has_many</code></p></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [R]
            </td>
            <td class='attr-name'>name</td>
            <td class='attr-desc'><p>Returns the name of the macro.</p>

<p><code>composed_of :balance, class_name: 'Money'</code> returns
<code>:balance</code> <code>has_many :clients</code> returns
<code>:clients</code></p></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [R]
            </td>
            <td class='attr-name'>options</td>
            <td class='attr-desc'><p>Returns the hash of options used for the macro.</p>

<p><code>composed_of :balance, class_name: 'Money'</code> returns <code>{
class_name: &quot;Money&quot; }</code> <code>has_many :clients</code>
returns +{}+</p></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [R]
            </td>
            <td class='attr-name'>scope</td>
            <td class='attr-desc'></td>
          </tr>
        
      </table>
    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-new">
            
              <b>new</b>(macro, name, scope, options, active_record)
            
            <a href="MacroReflection.html#method-c-new" name="method-c-new" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/b15ce4a006756a0b6cacfb9593d88c9a7dfd8eb0/activerecord/lib/active_record/reflection.rb#L110" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-new_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/reflection.rb, line 110</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">macro</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">scope</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">active_record</span>)
  <span class="ruby-ivar">@macro</span>         = <span class="ruby-identifier">macro</span>
  <span class="ruby-ivar">@name</span>          = <span class="ruby-identifier">name</span>
  <span class="ruby-ivar">@scope</span>         = <span class="ruby-identifier">scope</span>
  <span class="ruby-ivar">@options</span>       = <span class="ruby-identifier">options</span>
  <span class="ruby-ivar">@active_record</span> = <span class="ruby-identifier">active_record</span>
  <span class="ruby-ivar">@plural_name</span>   = <span class="ruby-identifier">active_record</span>.<span class="ruby-identifier">pluralize_table_names</span> <span class="ruby-operator">?</span>
                      <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">pluralize</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                  
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-3D-3D">
            
              <b>==</b>(other_aggregation)
            
            <a href="MacroReflection.html#method-i-3D-3D" name="method-i-3D-3D" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns <code>true</code> if <code>self</code> and
<code>other_aggregation</code> have the same <code>name</code> attribute,
<code>active_record</code> attribute, and <code>other_aggregation</code>
has an options hash assigned to it.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-3D-3D_source')" id="l_method-i-3D-3D_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/b15ce4a006756a0b6cacfb9593d88c9a7dfd8eb0/activerecord/lib/active_record/reflection.rb#L138" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-3D-3D_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/reflection.rb, line 138</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">==</span>(<span class="ruby-keyword ruby-title">other_aggregation</span>)
  <span class="ruby-keyword">super</span> <span class="ruby-operator">||</span>
    <span class="ruby-identifier">other_aggregation</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>) <span class="ruby-operator">&amp;&amp;</span>
    <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other_aggregation</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">&amp;&amp;</span>
    <span class="ruby-identifier">other_aggregation</span>.<span class="ruby-identifier">options</span> <span class="ruby-operator">&amp;&amp;</span>
    <span class="ruby-identifier">active_record</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other_aggregation</span>.<span class="ruby-identifier">active_record</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-class_name">
            
              <b>class_name</b>()
            
            <a href="MacroReflection.html#method-i-class_name" name="method-i-class_name" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns the class name for the macro.</p>

<p><code>composed_of :balance, class_name: 'Money'</code> returns
<code>'Money'</code> <code>has_many :clients</code> returns
<code>'Client'</code></p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-class_name_source')" id="l_method-i-class_name_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/b15ce4a006756a0b6cacfb9593d88c9a7dfd8eb0/activerecord/lib/active_record/reflection.rb#L132" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-class_name_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/reflection.rb, line 132</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">class_name</span>
  <span class="ruby-ivar">@class_name</span> <span class="ruby-operator">||=</span> (<span class="ruby-identifier">options</span>[<span class="ruby-value">:class_name</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">derive_class_name</span>).<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-klass">
            
              <b>klass</b>()
            
            <a href="MacroReflection.html#method-i-klass" name="method-i-klass" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns the class for the macro.</p>

<p><code>composed_of :balance, class_name: 'Money'</code> returns the Money
class <code>has_many :clients</code> returns the Client class</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-klass_source')" id="l_method-i-klass_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/b15ce4a006756a0b6cacfb9593d88c9a7dfd8eb0/activerecord/lib/active_record/reflection.rb#L124" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-klass_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/reflection.rb, line 124</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">klass</span>
  <span class="ruby-ivar">@klass</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">class_name</span>.<span class="ruby-identifier">constantize</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    